// 导入vue对象
import Vue from "vue";
// 导入Vuex 对象
import Vuex from "vuex";

Vue.use(Vuex);

// 抛出实例化的vuex的store对象
export default new Vuex.Store({
    // 五大核心数据
    state:{
        loading: false,
        bread: [],
        router_bread: [{
          to: '',
          name: ''
        }]
    },
    mutations:{
     // 修改loading的值
    changeLoading(state, loading) {
        state.loading = loading;
      },
      // 设置面包屑
      setBread(state, bread) {
        state.bread = bread
      },
      // 面包屑导航
      setRouterBread(state, route) {
        let index = state.router_bread.findIndex(item => {
          return item.to == route.to
        })
        if (index = -1) {
          state.router_bread.splice(index, 1)
        }
        state.router_bread.push(route)
      }
    },
    actions:{
        
    }
})